package com.itboye.jmsfhz.app.ui.me.personsettings;

import java.util.Observable;
import java.util.Observer;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.itboye.core.alert.ByAlert;
import com.itboye.core.object.BaseActivity;
import com.itboye.core.object.ResultEntity;
import com.itboye.core.object.SpPublicParams;
import com.itboye.core.utils.SPUtils;
import com.itboye.jmsfhz.R;
import com.itboye.jmsfhz.app.ui.main.MainPresenter;

public class ActivityUpdatePwdByPwd extends BaseActivity implements OnClickListener, Observer{

	EditText input_olderpwd,input_newpwd;
	Button btn_submit;
	private String newPwd;
	private String oldPwd;
	MainPresenter mainPresenter;
	private String uid;
	@Override
	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.activity_updatepwdbypwd;
	}

	@Override
	public void onMyCreate() {
		// TODO Auto-generated method stub
		mainPresenter=new MainPresenter(this);
		uid=(String) SPUtils.get(this, null, SpPublicParams.UID, "");
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v.getId()==R.id.btn_submit){
			oldPwd=input_olderpwd.getText().toString().trim();
			newPwd=input_newpwd.getText().toString().trim();
			mainPresenter.updatePasswordByPwd(uid, newPwd, oldPwd, "");
		}
	}

	@Override
	public void update(Observable observable, Object data) {
		// TODO Auto-generated method stub
		ResultEntity entity=handlerError(data);
		ByAlert.
		alert(entity.getData()+"");
	}

}
